import Cesium, { TilingScheme } from '../Ces/Cesium'
import WeImageryLayerFilterProvider from './WeImageryLayerFilterProvider'

class WeImageryLayerProvider {
  createComputeCommand: any
  _tileWidth: number
  _tileHeight: number
  _minimumLevel: number
  _maximumLevel: number
  _tilingScheme: TilingScheme
  _ready: boolean = false
  private _filterProvider: WeImageryLayerFilterProvider
  constructor(options) {
    options = options?? Cesium.Frozen.EMPTY_OBJECT
    this._tileWidth = options.tileWidth?? 512
    this._tileHeight = options.tileHeight?? 512
    this._minimumLevel = options.minimumLevel?? 0
    this._maximumLevel = options.maximumLevel?? 13
    if (options.filterUrl) {
      this._filterProvider = new WeImageryLayerFilterProvider({
        url: options.filterUrl
      })
    }
  }

  get filterProvider() {
    return this._filterProvider
  }

  get ready() {
    return this._ready
  }

  get rectangle() {
    return this.tilingScheme.rectangle
  }

  get tileWidth() {
    return this._tileWidth
  }

  get tileHeight() {
    return this._tileHeight
  }

  get minimumLevel() {
    return this._minimumLevel
  }

  get maximumLevel() {
    return this._maximumLevel
  }

  get tilingScheme() {
    return this._tilingScheme
  }

  get tileDiscardPolicy() {
    return undefined
  }

  get errorEvent() {
    return undefined
  }
  get credit() {
    return undefined
  }
  get proxy() {
    return undefined
  }
  get hasAlphaChannel() {
    return true
  }

  getTileCredits() {
    return undefined
  }

  pickFeatures() {
    return undefined
  }

  requestImage(x, y, level) {
    if (this._filterProvider) {
      return this._filterProvider.requestImage(x, y, level, this)
    }
    return Promise.resolve(true)
  }
}

export default WeImageryLayerProvider
